app.service('template', function($rootScope, $compile, $sce) {
  var that = this;

  this.get = function(name, data, target) {
    var html = that.tpl[name];
    var html_ = angular.element(html);
    var scope = $rootScope.$new();
    scope.title = data.title;
    scope.click_ = function(){
      console.log(data);
    };
    angular.element(document).ready(function(){
      angular.element(target).append($compile(html_)(scope));
    });
  };

  this.tpl = {
    tpl1: '<p style="background:red" ng-bind="title" ng-click="click_()"></p>',
  };
});
